package com.zhao.practice;

import com.zhao.utils.ElasticsearchUtils;
import lombok.extern.slf4j.Slf4j;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.transport.TransportClient;
import org.elasticsearch.rest.RestStatus;

import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Map;

@Slf4j
public class UpdateText {
    public static void main(String[] args) throws UnknownHostException {
        TransportClient transportClient = ElasticsearchUtils.getTransportClient();
        Map<String, String> map = new HashMap<>();
        map.put("content", "我叫王五，我来自天空之城");
        UpdateResponse updateResponse = transportClient.prepareUpdate("ems", "emp", "j98h6nwBpyyOYSG_LT5u").setDoc(map).get();
        RestStatus status = updateResponse.status();
        log.info("更新文本操作状态：", status.toString());
    }
}
